﻿Imports System.Windows.Forms

Public Class frmMain

    Private m_ChildFormNumber As Integer = 0

    Private Sub ShowNewForm(ByVal FrmChild As System.Windows.Forms.Form)
        FrmChild.MdiParent = Me
        FrmChild.Show()
    End Sub

    Private Sub FrmMain_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        If MessageBox.Show("Bạn muốn thoát khỏi chương trình không?", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) = Windows.Forms.DialogResult.OK Then
            Application.Exit()
        Else
            e.Cancel = True
        End If
    End Sub

    Private Sub FrmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Me.Enabled = False
        Me.ShowNewForm(frmChart)
    End Sub

    'Hiển thị các form
    Private Sub tbrTopMenu_ToolClick(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinToolbars.ToolClickEventArgs) Handles tbrTopMenu.ToolClick
        Try
            Select Case e.Tool.Key
                Case "mnuDangXuat"
                    Me.Close()
                    frmMainLogin.Show()
                Case "mnuSystem_Login"
                Case "mnuSystem_LogOut"
                Case "mnuSaoLuuCSDL"
                    frmBackupData.Show()
                Case "mnuPhucHoiCSDL"
                    frmRestoreData.Show()
                Case "mnuTinhTrangHopDong"
                    Me.ShowNewForm(frmTinhTrangHopDongList)
                Case "mnuChucDanh"
                    Me.ShowNewForm(frmChucDanhList)
                Case "mnuNhomViTri"
                    Me.ShowNewForm(frmNhomViTriList)
                Case "mnuViTriCongViec"
                    Me.ShowNewForm(frmViTriCongViecList)
                Case "mnuNhanVien"
                    Me.ShowNewForm(frmNhanVienList)
                Case "mnuLoaiDoiTuong"
                    Me.ShowNewForm(frmLoaiKhachHangNhaCCList)
                Case "mnuDoiTuong"
                    Me.ShowNewForm(frmKhachHangNhaCCList)
                Case "mnuLoaiHangHoa"
                    Me.ShowNewForm(frmLoaiVatTuHangHoaList)
                Case "mnuHangHoa"
                    Me.ShowNewForm(frmHangHoaVatTuList)
                Case "mnuHopDongLaoDong"
                    Me.ShowNewForm(frmHopDongLDList)
                Case "mnuLoaiHopDongLD"
                    Me.ShowNewForm(frmLoaiHopDongLDList)
                Case "mnuHopDongMua"
                    Me.ShowNewForm(frmHopDongMuaList)
                Case "mnuHopDongBan"
                    Me.ShowNewForm(frmHopDongBanList)
                Case "mnuTienTe"
                    Me.ShowNewForm(frmLoaiTienList)
                Case "mnuThongTin"
                    FrmInfoApplication.Show()
                Case "mnuBaoCaoHDTheoTinhTrang"
                    frmBaoCaoTinhTrangHopDong.Show()
            End Select
        Catch ex As Exception
            MessageBox.Show(ex.ToString, "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Sub

    Private Sub menuLeft_ItemClick(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinExplorerBar.ItemEventArgs) Handles menuLeft.ItemClick
        Select Case e.Item.Key
            Case "mnuLeft_HangHoaVatTu"
                Me.ShowNewForm(frmHangHoaVatTuList)
            Case "mnuLeft_NhanVien"
                Me.ShowNewForm(frmNhanVienList)
            Case "mnuLeft_HopDongMua"
                Me.ShowNewForm(frmHopDongMuaList)
            Case "mnuLeft_HopDongBan"
                Me.ShowNewForm(frmHopDongBanList)
            Case "mnuLeft_HopDongLD"
                Me.ShowNewForm(frmHopDongLDList)
        End Select
    End Sub

End Class
